#include "stdafx.h"
#include "cassert"

void insertionsort(int* pIn ,int length)
{
	assert(length>0);
	if (length==1)
	{
		return;
	}
	int key=0,j=0;;
	for (int i=1;i<length;++i)
	{
		key=pIn[i];
		j=i-1;
		while((j>=0)&&(pIn[j]>key))
		{
			pIn[j+1]=pIn[j];
			--j;
		}
		pIn[j+1]=key;
	}
}